﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;

namespace HenIT.CAGCompare
{
    public static class NetTools
    {
        public static bool IsValidMachineName(string machineName)
        {
            try
            {
                if (Dns.GetHostAddresses(machineName).Length > 0)
                {
                    return true;
                }
                else
                {
                    MessageBox.Show("The computer named '" + machineName + "' does not exist or cannot be accessed!",
                        "Adding", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            catch (System.Net.Sockets.SocketException)
            {
                MessageBox.Show("The computer named '" + machineName + "' does not exist or cannot be accessed!",
                        "Adding", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            return false;
        }
    }
}
